<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Dcat\Admin\Admin;

Admin::routes();

Route::group([
    'prefix'     => config('admin.route.prefix'),
    'namespace'  => config('admin.route.namespace'),
    'middleware' => config('admin.route.middleware'),
], function (Router $router) {

    $router->get('/', 'HomeController@index');
    $router->any('images/upload', 'ImageController@handle');
    //项目
    $router->resource('project', 'SrProjectController');
    $router->get('detail/{project_id}', 'SrDetailController@detail_index');
    $router->get('detail/{project_id}/create', 'SrDetailController@detail_create');
    $router->post('detail/{project_id}', 'SrDetailController@detail_store');
    $router->get('detail/{project_id}/{id}/edit', 'SrDetailController@detail_edit');
    $router->put('detail/{project_id}/{id}', 'SrDetailController@detail_update');
    $router->delete('detail/{project_id}/{id}', 'SrDetailController@detail_destroy');


});

//动态路由
//$api = \App\Models\SrDetail::with('project')->where('on', 0)->get();
//foreach ($api as $v){
//    Route::match($v->method,$v->project->baseurl.$v->url, function () use ($v) {
//        return response()->json(json_decode($v->result));
//    });
//}
